/*
Contains:
	all of the vars used by each type of mob
	what happens when a mob is clicked, by default
	the basic procs related to every mob (death, lose hp, etc)
	the verbs used by players via interface, or other explicit calls
*/

mob

	LeftClick(player/clicker, loc, control, params)
		clicker.target(src)

	var
		stat
			hp

		base_power	= 0
		power		= 0

		base_sustain= 0
		sustain		= 0

		base_range	= 0
		range		= 0

		speed_cast 	= 20

		speed_move 	= 10

		level		= 0

		class		= 0
		subclass	= 0

		resistance	= 0
		weaknesses	= 0

		ac			= 0

		alliance	= 0

		bonus		= 0
		attack_bonus= 0

		hit_die = "1d20"
		dam_die = "2d4"

		attack_delay 		= 10
		move_delay 			= 2

		tmp
			can_cast= 1
			can_move= 1
			can_atk = 1

			mob
				target

		list
			equipment = list("Book","Body")

	proc
		death(mob/killer)

		levelup()

			//if(class & SUPPORT) //this class does not get any levelup bonuses. sad day.

			if(class & MAGICAL)
				base_power++	//more power
				if(level & 1)
					bonus++			//more ac penetration every other level

			if(class & RESTORE)
				base_sustain++	//more quick restoration

			if(class & RANGED )
				if(level % 5)	//having a base range of 20 would be ridiculous -- lets cap it at 4.
					base_range++
				hp.set_max(hp.get_maximum()+(round(hp.get_maximum() * 0.01)))	//but add more hp too

		attack(mob/target)
			if(!can_atk) return
			can_atk = 0
			spawn(attack_delay)
				can_atk=1

			dir = get_dir(src, target)

			var/x = roll(hit_die)
			if(x == 20)
				target.take_damage(src, (roll(dam_die)*3)+calc_bonus(POWER), "#ff0000")

				if(isplayer(src) && ismonster(target))
					var/monster/m = target
					m.move_delay = 20
					step(target, dir)
					step(target, dir)

			else if(x+bonus>target.ac)
				x = min(roll(dam_die), rand(1,7))+calc_bonus(POWER)
				target.take_damage(src, x, "#ff0000")

				if(isplayer(src) && ismonster(target))
					var/monster/m = target
					m.move_delay = 6
					step(target, dir)

		take_damage(mob/hitter, damage, color)
			if(!hp || hp.at_min()) return
			F_damage(src, damage, color)
			if(hp) hp.decrease(damage)
			check_for_death_from(hitter)

		check_for_death_from(mob/killer)
			if(hp.at_min())
				view() << "[src] has died at the hands of [killer]."
				death(killer, 1)

		regen_hp()

		target(mob/m)

		gain_exp(amount)

		calc_bonus(bit)
			var/armor/a = BODY
			var/book/b = BOOK

			if(a && a.stat_boost & bit) . += a.stat_boost & ~bit

			if(b && b.stat_boost & bit) . += b.stat_boost & ~bit

		can_equip(obj/item/i)
			if(i.restriction)
				if(i.restriction & LIGHTMAG)if(!(subclass && (subclass & LIGHTMAG)))
					src << "The armor's immense brightness overwhelms you."
					i.Move(loc)
					return 0

				if(i.restriction & DARKMAG ) if(!(subclass && (subclass & DARKMAG )))
					src << "The armor's darkness overwhelms you."
					i.Move(loc)
					return 0

				if(!(i.restriction & class))
					src << "The armor shocks you, and it falls to the ground."
					i.Move(loc)
					return 0

			return 1

mob/verb/attackmob()
	set hidden = 1
	for(var/mob/m in get_step(src,dir))
		attack(m)
		break

mob/verb/get()
	set hidden = 1
	for(var/obj/item/o in loc)
		o.Move(src)
		src << "You got [o]."
		break